package com.huitone.smspfm.dao.oracle;

import com.huitone.smspfm.logger.ExtLogger;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;

import com.huitone.smspfm.dao.oracle.entity.PriRuleDef;

public class PriRuleDefDao extends BaseDao<PriRuleDef> {
	
	private static ExtLogger logger = ExtLogger.create(PriRuleDefDao.class);

	/**
	 * 获取优先级最小的一条记录，即level值最大的那一条记录
	 * @return
	 */
	public PriRuleDef getMinLevel() {
		
		PriRuleDef result = null;
		
		try {
			result = jdbcTemplate.queryForObject("SELECT * FROM " + tableName + " WHERE \"LEVEL\" = (SELECT MAX(\"LEVEL\") FROM " + tableName + " WHERE STATUS = '1')", new BeanPropertyRowMapper<>(PriRuleDef.class));
		} catch (EmptyResultDataAccessException e) {
			logger.error("优先级配置表没有数据:" + e.getMessage());
		}
		
		return result;
	}
}
